import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import VueRout from 'vue-router'
import '@/icons' // icon
import '@/permission' // permission control
import  permiss  from '@/directive/permission'
import api from '@/api/index.js'
Vue.prototype.$api = api
import Vant from 'vant';
import 'vant/lib/index.css';
Vue.use(Vant,VueRout);
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
if (process.env.NODE_ENV === 'production') {
  const { mockXHR } = require('../mock')
  mockXHR()
}
//转为大写
Vue.filter('myNum',function(num){
   var arr1 = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']
  
   var arr2 = ['', '十', '百', '千', '万', '十', '百', '千', '亿', '十', '百', '千', '万', '十', '百', '千', '亿']
  
  if (!num || isNaN(num)) return '零'
  
   var english = num.toString().split('')
  
  var result = ''
  
   for (var i = 0; i < english.length; i++) {
  
   var des_i = english.length - 1 - i// 倒序排列设值
  
   result = arr2[i] + result
  
   var arr1_index = english[des_i]
  
   result = arr1[arr1_index] + result
  
  }
  
  result = result.replace(/零(千|百|十)/g, '零').replace(/十零/g, '十') // 将【零千、零百】换成【零】 【十零】换成【十】

   result = result.replace(/零+/g, '零') // 合并中间多个零为一个零
  
   result = result.replace(/零亿/g, '亿').replace(/零万/g, '万') // 将【零亿】换成【亿】【零万】换成【万】
  
   result = result.replace(/亿万/g, '亿') // 将【亿万】换成【亿】
  
  result = result.replace(/零+$/, '') // 移除末尾的零
  
  // 将【一十】换成【十】
  
  result = result.replace(/^一十/g, '十')
   return result
  })
  // 关闭警告
  Vue.config.silent = true;
// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI)
// 自定义指令-动态按钮权限,获取所有的按钮权限
Vue.directive('permission',permiss)
Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
